********************************************************************************
* This file estimates the cash demand as a function of liquidity cost measured by
* 3m tbill rate, AAA corporate bond rate and spread btween these two. 
* Cyclical components of these costs are obtained by Band Pass filter
* Use compustat_final.do file to call this file.
* 
********************************************************************************


********************************************************************************
* This file estimates the cash demand as a function of liquidity cost measured by
* 3m tbill rate, AAA corporate bond rate and spread btween these two. 
* Cyclical components of these costs are obtained by HP filter
* Use compustat_log_final.do file to call this file.
* 
********************************************************************************

********************************************************************************
*regress cash and equivalent holding on CPI inflation final version 
* variables normalized by total asset
********************************************************************************

estimates clear 

qui:xtreg cheat cpi_inflation_final logat_cpi_final ebitat if at>=0 ,r
estimates store m1
qui:xtreg cheat cpi_inflation_final logat_cpi_final ebitat lratio_c capxat if at>=0 ,r
estimates store m2
qui:xtabond cheat cpi_inflation_final logat_cpi_final ebitat lratio_c capxat if at>=0 ,vce(robust)
estimates store m3

qui:xtreg cheat cpi_inflation_final_bkc logat_cpi_final ebitat if at>=0 ,r
estimates store m4
qui:xtreg cheat cpi_inflation_final_bkc logat_cpi_final ebitat lratio_c capxat if at>=0 ,r
estimates store m5
qui:xtabond cheat cpi_inflation_final_bkc logat_cpi_final ebitat lratio_c capxat if at>=0 ,vce(robust)
estimates store m6


esttab m1 m2 m3 m4 m5 m6 using "tables/md_at_cpi_final_bk_log_final.tex",  keep(cpi_inflation_final cpi_inflation_final_bkc logat_cpi_final ebitat lratio_c capxat L.cheat ) cells(b(star fmt(3)) se(par fmt(3))) stats(r2_a r2_w N) starlevels(* 0.10 ** 0.05 *** 0.01) varlabels(L.cheat "Lag Liquidity" ebitat "Sales" logat_r "Log Asset" lratio_c "Leverage" capxat "Capital Exp." ppi_inflation "Inflation" ppi_inflation_c "Inflation (Cycle)")  nonumbers mtitles("Raw" "Raw" "Raw" "Cycle"  "Cycle" "Cycle") addnotes("Robust standard errors are in brackets and are clustered at firm level.") legend replace

esttab m1 m2 m3 m4 m5 m6 using "tables/md_at_cpi_final_bk_log_final.csv",  keep(cpi_inflation_final cpi_inflation_final_bkc logat_cpi_final ebitat lratio_c capxat L.cheat ) cells(b(star fmt(3)) se(par fmt(3))) stats(r2_a r2_w N) starlevels(* 0.10 ** 0.05 *** 0.01)  varlabels(L.cheat "Lag Cash Holding" ebitat "Sales" logat_r "Log Asset" lratio_c "Leverage" capxat "Capital Exp." ppi_inflation "Inflation" ppi_inflation_c "Inflation (Cycle)")  nonumbers mtitles("Raw" "Raw" "Raw" "Cycle"  "Cycle" "Cycle") addnotes("Robust standard errors are in brackets and are clustered at firm level.") legend replace
